<#ftl output_format="HTML" auto_esc=true>
<@h.commonHead title="后台管理系统" keywords="开源,永久免费" description="springrain开源系统管理后台"/>

<script src="${ctx}/js/validform/validform.min.js"></script>
<link rel="stylesheet" href="${ctx}/js/validform/validform.css" media="all">
<script>
	 var formObj = null;
	 jQuery(function(){
		 /*
		 init_valid(_before,_after)
		 @_before:提交表单前，调用 的函数   可以为空，一般有validform处理不了，独自进行处理时使用
		 @_after:保存成功后，调用的函数  可以为空，一般为对应的列表页面
		 */
		 formObj = springrain.initValid(null,function(){window.location.href="${ctx}/s/${siteId!''}/${businessId!''}/questionnaireanswer/list?springraintoken="+springraintoken});
	 });
	 
	 /** 保存 **/
	 function save(){
		var isPass = formObj.check(true);
		if(isPass){
			// saveBtn
			$("#saveBtn").prop("disabled",true);
			$.ajax({
				 url: "${ctx}/s/${siteId!''}/${businessId!''}/questionnaireanswer/update" ,
				 data: $("#validForm").serialize(),
				 type: "POST" ,
				 success: function(_data){
					 if(_data.status == "success"){
						layer.msg("保存成功！", {
							icon: 1,
							time: 2000 //2秒关闭（如果不配置，默认是3秒）
						}, function(){
							springrain.goTo("${ctx}/s/${siteId}/${businessId}/questionnaireanswer/list?questionId=${questionId!''}");	
						});
					 }else{
						 $("#saveBtn").prop("disabled",false);
						 layer.msg(_data.message, {
							icon: 1,
							time: 2000 //2秒关闭（如果不配置，默认是3秒）
						}, function(){
							
						});
					 }
				 }
			 });	
		}
	 }
</script>
</head>
<body>
	<div class="layui-layout layui-layout-admin">
		<@h.naviHeader /><@h.leftMenu />
		<!-- 主体内容开始 -->
			<div class="layui-tab layui-tab-brief">
				<ul class="layui-tab-title site-demo-title">
		             <li style="float:right;">
				        <button type="button" onclick="history.go(-1)" class="layui-btn layui-btn-small" style="margin-top:8px;"><i class="layui-icon layui-icon-specil">&#xe603;</i>返回</button>
		             </li>
	       		</ul>
				
				<div class="layui-body layui-tab-content site-demo-body">
					<div class="layui-tab-item layui-show">
							<div class="layui-main">
						          <div id="LAY_preview" class="layui-my-form">
						          				<header class="larry-personal-tit">
													<span>添加答案表</span>
												</header>
												<div class="larry-personal-body clearfix changepwd">
													<@questionnaire_answer id=id!'' >
													<form id="validForm" class="layui-form <!--  -->"  method="post" >
														<input type="hidden" id="id" name="id" value="${id!''}"/>	
														<input type="hidden" id="questionId" name="questionId" value="${questionId!''}"/>	
														<div class="layui-form-item col-lg-6">
															<label class="layui-form-label">答案内容*</label>
															<div class="layui-inline col-lg-5">  
																<input type="text" name="content" id="content" datatype="*" nullmsg="不能为空" errormsg="不能为空！" autocomplete="off" class="layui-input" value="${(tag_bean.content)!''}">
															</div>
															<div class="layui-inline valid-info"></div>
														</div>
														<div class="layui-form-item col-lg-6">
															<label class="layui-form-label">答案类型*</label>
															<div class="layui-inline col-lg-5">  
																<select name="answerType" id="answerType" lay-verify="required">
															 		<#if tag_bean?? && tag_bean.answerType == 1>
																 		<option value="1" selected="selected">固定内容</option>
																 		<option value="2" >可填写</option>
																 	<#elseif tag_bean?? && tag_bean.answerType == 2>
																 		<option value="1" >固定内容</option>
																 		<option value="2" selected="selected">可填写</option>
																 	<#else>
																 		<option value="1" selected="selected">固定内容</option>
																 		<option value="2" >可填写</option>
															 		</#if>
															    </select>
															</div>
															<div class="layui-inline valid-info"></div>
														</div>
														<input type="hidden" id="correct" name="correct" value="1" >
														<div class="layui-form-item col-lg-6">
															<label class="layui-form-label">是否可用</label>
															<div class="layui-inline col-lg-5">  
																<select name="active" id="active" lay-verify="required">
															 		<#if tag_bean?? && tag_bean.active == 1>
																 		<option value="1" selected="selected">是</option>
															 			<option value="0" >否</option>
																 	<#elseif tag_bean?? && tag_bean.active == 0>
																 		<option value="1" >是</option>
															 			<option value="0" selected="selected">否</option>
																 	<#else>
																 		<option value="1" selected="selected">是</option>
															 			<option value="0" >否</option>
															 		</#if>
															    </select>
															</div>
															<div class="layui-inline valid-info"></div>
														</div>
														<div class="layui-form-item col-lg-6">
															<label class="layui-form-label">序号 *</label>
															<div class="layui-inline col-lg-5">  
																<input type="text" name="sortno" id="sortno" datatype="*" nullmsg="不能为空" errormsg="不能为空！" autocomplete="off" class="layui-input" value="${(tag_bean.sortno)!''}">
															</div>
															<div class="layui-inline valid-info"></div>
														</div>
													<div class="layui-form-item change-submit">
													<label class="layui-form-label"></label>
															<div class="layui-inline">
																<button type="button" class="layui-btn" id="saveBtn" onclick="save();">保存</button>
																<button type="button" class="layui-btn layui-btn-primary" id="rstbtn">重置</button>
															</div>
														</div>
													</form>
													</@questionnaire_answer>
												</div>
								  </div>
							</div>
					</div>
			</div>
		</div>
		<!-- 主体内容结束 -->
		<@h.footer />
	</div>
</body>
</html>
